using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using StockExchanger.Models;

namespace StockExchanger.Controllers {

    public class JsonDse {
        public int      DseID    { get; set; }
        public string   Title       { get; set; }
        public double   Latitude    { get; set; }
        public double   Longitude   { get; set; }
        public string   Description { get; set; }
        public int      RSVPCount   { get; set; }
    }

    public class SearchController : Controller {
/*
        IDseRepository DseRepository;

        //
        // Dependency Injection enabled constructors

        public SearchController()
            : this(new DseRepository()) {
        }

        public SearchController(IDseRepository repository) {
            DseRepository = repository;
        }

        //
        // AJAX: /Search/FindByLocation?longitude=45&latitude=-90

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult SearchByLocation(float latitude, float longitude) {

            var Stock = DseRepository.FindByLocation(latitude, longitude);

            var jsonStock = from Dse in Stock
                              select new JsonDse {
                                  DseID = Dse.DseID,
                                  Latitude = Dse.Latitude,
                                  Longitude = Dse.Longitude,
                                  Title = Dse.Title,
                                  Description = Dse.Description,
                                  RSVPCount = Dse.RSVPs.Count
                              };

            return Json(jsonStock.ToList());
        }
*/    }
}
